Reuse local image when already present for pinned tags#339
Merged
gtsiolis merged 2 commits intoJun 25, 2026
Conversation
lstk ran docker pull on every start, even when the image was already present locally. On slow networks this meant repeated multi-minute re-downloads for no benefit. Add ImageExists to the Runtime interface (backed by ImageInspect + errdefs.IsNotFound on Docker) and, in pullImages, skip the pull for pinned tags whose image is already local. Emit a "Using local image" message and record pulled[name]=false so start telemetry does not over-count. Floating latest/empty tags still pull until pull_policy support lands. Generated with [Linear](https://linear.app/localstack/issue/PRO-323/reuse-local-image-when-already-present#agent-session-e6210615) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
…olated The previous version started a real LocalStack bound to the shared host port 4566, which collided with the external-container tests after CI's sorted-name shard reshuffle and caused a leaked-container cascade. Tag the lightweight alpine test image under a pinned localstack-pro tag instead: lstk still skips the pull and emits "Using local image" (the decision under test, emitted before the container starts), but the stand-in image exits immediately so start fails fast. A dedicated host port (4599) keeps it off 4566. No real image pull or auth token needed. Generated with [Linear](https://linear.app/localstack/issue/PRO-323/reuse-local-image-when-already-present#agent-session-e6210615) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
anisaoshafi
approved these changes
Jun 25, 2026
anisaoshafi
left a comment
Collaborator
There was a problem hiding this comment.
Good improvement, nice thought. No need to pull images that are already downloaded 💯 Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lstk startrandocker pullon every start, even when the image was already present locally —rt.PullImagewas unconditional. On slow networks this meant repeated multi-minute re-downloads for no benefit.This adds
ImageExiststo theRuntimeinterface (backed byImageInspect+errdefs.IsNotFoundon Docker) and, inpullImages, skips the pull when a pinned-tag image is already local — emitting aUsing local imagemessage instead and recordingpulled[name]=falseso start telemetry (LifecycleStartSuccess.Pulled) doesn't over-count. Stopped-container cleanup (rt.Remove) still runs on both branches, and post-pull license validation is unaffected since the image is present.A net-new probe is needed because
GetImageVersioncan't double as one: it errors both when the image is absent and whenLOCALSTACK_BUILD_VERSIONis missing, conflating the two.Scope
Skip-if-present applies to pinned tags only. Floating
latest/empty still pulls until thepull_policywork lands (PRO-325).Tests
lstk start, assertUsing local imagepresent andPullingabsent.ImageExiststrue → 0PullImagecalls,pulled[name]==false; false → 1 call,pulled[name]==true.